package com.qf.hospital.serialize;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/10/19 11:10
 */
public class Integer2BooleanJsonSerialize extends JsonSerializer<Integer> {
    @Override
    public void serialize(Integer integer, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        //Integer的值为1，写回true，否则写回false
        jsonGenerator.writeBoolean(integer==1);
    }
}
